//引入封装好的ajax后期使用
import ajax from './ajax'
//路径
const url = 'http://demo.itlike.com/web/xlmc/api/'
//请求首页的数据
export const home = ()=>ajax(url+'homeapi')
//分类数据
//左侧
export const cateLeftApi = ()=>ajax(url+'homeapi/categories')
//右侧
export const cateRightApi = (params)=>ajax(url+'homeapi/categoriesdetail/lk'+params)
//购物车
// 短信验证
// 1. 获取验证码
// export const getVerCodeApi = (phone)=>ajax(url+'send_code?phone='+phone);
export const getVerCodeApi = (phone)=>ajax(url+'send_code',{phone});
//登录ajax
export const toTelLoginApi = (phone,code)=>ajax(url+'login_code',{phone,code},"POST");
//登录状态
// http://demo.itlike.com/web/xlmc/api/userinfo
// export const reqLoginApi = (token)=>ajax(url+'userinfo',{token});

//购物车中添加商品
// http://demo.itlike.com/web/xlmc/api/cart/add
// goods_id: goods_name: goods_price: small_image:  user_id: 
export const addCartApi = (goods)=>ajax(url+'cart/add',goods,"POST");
//请求购物车的数据,token
export const reqCartApi = (token)=>ajax(url+`cart/search/${token}`,{},"GET");
/* 数量加减 */
/* 
	post 
	@params{goods_id}
	@params{type|"add"  "reduce"}
	@params{user_id}
 */
export const cartChangeNumApi = (goods_id,type="add",user_id)=>ajax(url+'cart/num',{goods_id,type,user_id},"POST");
// 减
export const cartReduceNumApi = (goods_id,type="add",user_id)=>ajax(url+'cart/num',{goods_id,type,user_id},"POST");
// 获取服务端选中的购物车商品
// /api/cart/selected/user_id
export const selectCartsGoodsApi = (user_id)=>ajax(url+'cart/selected/'+user_id);

//地址的请求
// address/search/
export const reqAddressApi = (token)=>ajax(url+`address/search/${token}`);
// address_area:  区域
// address_area_detail: 详细地址 
// address_name: 名字
// address_phone: 电话
// address_post_code:  邮政编码
// address_tag:  是否默认
// areaCode: 区域的code
// city:  城市
// county:  区
// province:  省
// user_id: token
//给服务器添加地址
export const addAddressApi = (addressDetail)=>ajax(url+`address/add/`,addressDetail,"post");
//删除已保存地址的接口
// 4.4 删除用户的地址
export const delAddress = (address_id) => ajax(url+ 'address/del/'+ address_id);